#ifndef _EXCEPT_H
#define _EXCEPT_H
#include <string>
using namespace std;

class ClientException: public exception
{
public:
	//构造函数
	ClientException(void):m_msg("client error!"){}
	//重载构造函数
	ClientException(string const& msg):m_msg("client error!"){
		m_msg += msg;
		m_msg += "!";
	}
	
	//析构函数
	~ClientException(void) throw(){}
	
	//返回错误信息的描述
	char const* what(void)const throw (){
		//c_str()函数返回一个指向正规C字符串的指针,内容与本string串相同
		return m_msg.c_str();
	}
	
	private:
		//保存错误信息的数据成员
		string m_msg;
};

//备份异常
class BackupException:public ClientException
{
public:
	BackupException(void):ClientException("backup error"){}
	BackupException(string const& msg):ClientException(msg){}
};

//读取异常
class ReadException:public ClientException
{
public:
	ReadException(void):ClientException("read error"){}
	ReadException(string const& msg):ClientException(msg){}
};

//保存异常
class SaveException:public ClientException
{
public:
	SaveException(void):ClientException("save error"){}
	SaveException(string const& msg):ClientException(msg){}
};

//创建socket异常
class SocketException:public ClientException
{
public:
	SocketException(void):ClientException("socket error"){}
	SocketException(string const& msg):ClientException(msg){}
};

//发送异常
class SendException:public ClientException
{
public:
	SendException(void):ClientException("send error"){}
	SendException(string const& msg):ClientException(msg){}
};

#endif
